#include <string.h>
#include <stdio.h>

char * sub_string(unsigned char * des, unsigned char * src, unsigned int len)
{
	char *tmp = des;

	while(len > 0 && len--) {
		*des++ = *src++;
	}

	return tmp;
}


int main()
{
	char *haystack = "aaa||bbb||ccc||eee";
	char *needle = "||";
	char *buf = strstr( haystack, needle);
	char ch[10] = "1";
	char *p;

	char dddd[30] = "xiaozhiwise";

	while( buf != NULL )
	{
		printf("haystack = %s\n ", haystack);			// aaa||bbb||ccc||eee,	bbb||ccc||eee,	ccc||eee
		printf("buf = %s\n", buf);						// ||bbb||ccc||eee,		||ccc||eee,		||eee
		haystack = buf + strlen(needle);
		/* Get next token: */
		buf = strstr( haystack, needle);
	}

	printf("%d\n", atoi(ch));				// 1

	p = sub_string(ch, dddd+4, 4);
	printf("%s\n", p);						// zhiw

	printf("%ld\n", strlen("xia\0as22"));	// 3
	printf("%d\n", '9' - '0');				// 9

	return 0;
}
